package com.jugheadzhou.aop.config;

import com.jugheadzhou.aop.advisor.TaskExceptionAnnotationAdvisor;
import com.jugheadzhou.aop.advisor.TaskExceptionAnnotationInterceptor;
import com.jugheadzhou.aop.annotation.TaskExceptionHandle;
import org.springframework.aop.Advisor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;

@Configuration
public class AppAutoConfig {

    @Bean
    public Advisor dynamicDatasourceAnnotationAdvisor() {
        TaskExceptionAnnotationInterceptor interceptor = new TaskExceptionAnnotationInterceptor();
        TaskExceptionAnnotationAdvisor advisor = new TaskExceptionAnnotationAdvisor(interceptor, TaskExceptionHandle.class);
        advisor.setOrder(Ordered.HIGHEST_PRECEDENCE);
        return advisor;
    }

}
